package com.bm.controller;

import com.bm.Do.owner.OwnerApplyListDo;
import com.bm.Do.owner.OwnerListDo;
import com.bm.Result.CodeEnum;
import com.bm.Result.Result;
import com.bm.Vo.owner.OwnerApplyDetailVo;
import com.bm.Vo.owner.OwnerApplyReplyVo;
import com.bm.Vo.owner.OwnerApproveVo;
import com.bm.Vo.owner.OwnerDetailVo;
import com.bm.query.Common.InfoQuery;
import com.bm.query.owner.OwnerApplyListQuery;
import com.bm.query.owner.OwnerApplyReplyQuery;
import com.bm.query.owner.OwnerApproveQuery;
import com.bm.query.owner.OwnerListQuery;
import com.bm.service.EjyyOwnerApplyService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 86134
 * @version 1.0
 * @description TODO
 * @date 2024/3/26 19:52
 */
@RestController
@Api(tags = "人力资源相关接口")
public class OwnerController {

    @Autowired
    private EjyyOwnerApplyService ownerApplyService;

    @PostMapping("/owner/apply_list")
    @ApiOperation(value = "查询所有回复api")
    public Result OwnerApplyList(@RequestBody OwnerApplyListQuery ownerApplyListQuery) {
        PageInfo<OwnerApplyListDo> list = ownerApplyService.ownerApplyList(ownerApplyListQuery);
        return Result.OK(list);

    }

    @PostMapping("/owner/apply_reply")
    @ApiOperation(value = "申请答复")
    public Result OwnerApplyReply(@RequestBody OwnerApplyReplyQuery ownerApplyReplyQuery) {
        OwnerApplyReplyVo ownerApplyReplyVo = ownerApplyService.OwnerApplyReply(ownerApplyReplyQuery);
        return Result.OK(ownerApplyReplyVo);
    }

    @PostMapping("/owner/approve")
    @ApiOperation(value = "申请批准")
    public Result OwnerApprove(@RequestBody OwnerApproveQuery ownerApproveQuery) {
        OwnerApproveVo ownerApplyReplyVo = ownerApplyService.ownerApprove(ownerApproveQuery);
        return ownerApplyReplyVo == null ? Result.FAIL(CodeEnum.QUERY_APPROVE_ILLEFAL) : Result.OK(ownerApplyReplyVo);
    }

    @PostMapping("/owner/detail")
    @ApiOperation(value = "人力资源详情")
    public Result OwnerDetail(@RequestBody InfoQuery infoQuery) {
        OwnerDetailVo ownerDetailVo = ownerApplyService.ownerDetail(infoQuery);
        return ownerDetailVo == null ? Result.FAIL(CodeEnum.QUERY_ILLEFAL_TO_USER) : Result.OK(ownerDetailVo);
    }

    @PostMapping("/owner/list")
    @ApiOperation(value = "查看所有员工信息")
    public Result OwnerList(@RequestBody OwnerListQuery ownerListQuery){
        PageInfo<OwnerListDo> pageInfo = ownerApplyService.ownerList(ownerListQuery);
        return Result.OK(pageInfo);
    }

    @PostMapping("/owner/apply_detail")
    @ApiOperation(value = "申请详情")
    public Result OwnerApplyDetail(@RequestBody InfoQuery infoQuery){
        OwnerApplyDetailVo ownerApplyDetailVo = ownerApplyService.ownerApplyDetail(infoQuery);
        return ownerApplyDetailVo == null ? Result.FAIL(CodeEnum.QUERY_ILLEFAL_TO_USER) : Result.OK(ownerApplyDetailVo);
    }


}
